package com.zzh.net.utils;

import com.google.gson.Gson;


import okhttp3.RequestBody;

/**
 * @author fengyanjie
 * @email 506284835@qq.com
 * @date 2020-03-21
 * @desc 网络请求转换类
 */
public class NetRequestUtils {
    private static final String TAG = NetRequestUtils.class.getSimpleName();
    private static Gson gson = new Gson();

    /**
     * Retrofit 网络请求 josn转换为 RequestBody
     */
    public static RequestBody getRequestBody(String obj) {
        return RequestBody.create(okhttp3.MediaType.parse("application/json; charset=utf-8"), obj);
    }

    /**
     * Retrofit 网络请求 obj转换为 RequestBody
     */
    public static RequestBody getRequestBody(Object obj) {
        return RequestBody.create(okhttp3.MediaType.parse("application/json; charset=utf-8"), gson.toJson(obj));
    }
}
